<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8"/>
    <meta name="keywords" content=""/>
    <meta name="description" content=""/>
    <title>管理平台</title>
    <link rel="stylesheet" href="${base}/static/layui/css/layui.css"/>
   <!-- <link rel="stylesheet" href="${base}/static/css/admin.css"/>-->
</head>
<body>
    <form class="layui-form" id="adminform" action="${base}/careRecord/save">
		<input name="personId" value="${userId}" type="hidden" />
		<div class="layui-form-item" style="margin-top: 50px">
			<label class="layui-form-label">产品：</label>
			<div class="layui-input-block">
				<%if(goodsList.~size==0){%>
				当前无剩余产品可用，请购买新产品！
				<%}%>
				<%for (goods in goodsList) {%>
				<input type="checkbox" name="goodsId" value="${goods.id}" title="${goods.name}  ${goodsJSONFormat(goods.goodsSnapshot,2)}">
				<%}%>
			</div>
		</div>
		<div class="layui-form-item" style="width: 40%">
			<label class="layui-form-label">护理人：</label>
			<div class="layui-input-block">
				<select name="userId" lay-filter="aihao" >
					<option value="0">默认（业务员）</option>
					<%for (user in userList) {%>
					<option value="${user.id}">${user.name}</option>
					<%}%>
				</select>
			</div>
		</div>
		<div class="layui-form-item" style="width: 40%">
			<label class="layui-form-label">护理时间：</label>
			<div class="layui-inline">
				<div class="layui-input-inline">
					<input class="layui-input layui-date" placeholder="点击选择护理时间" id="start" name="dateTime">
				</div>
			</div>
		</div>
		<div style="margin-left: 145px; margin-bottom: 15px;">	
			<div class="layui-btn" id="adminBut" style=" min-width: 150px;">确定</div>
		</div>
	</form>

	<script type="text/javascript" src="${base}/static/layui/jquery.min.js"></script>
	<script type="text/javascript" src="${base}/static/layui/layui.js"></script>
	<script type="text/javascript" src="${base}/static/js/jquery.form.js"></script>
	<script type="text/javascript" src="${base}/static/js/util.js"></script>
	<script>

        $("#adminBut").click(function() {
          $("#adminform").ajaxSubmit({
                clearForm: false,
                dataType: "JSON",
                success: function(data) {
                    if(data.code==200){
                        layer.msg('添加记录成功！',{time: 2000});
                        closeThisWindowAndParentReload(1500);
                    }else if(data.code==301){
                        layer.msg(data.message,{time: 2000});
                      /*  closeThisWindowAndParentReload(1500);*/
					}else{
                        layer.msg(data.message,{time: 2000});
					}
                },
                error: function(){
                    layer.msg('添加失败！',{time: 1000});
				}
        });
        });
		layui.use(['jquery','form','upload','layer','laydate'], function(){
            var $ = layui.jquery
                ,layer = layui.layer
                ,form = layui.form();


            // 开始时间及截止时间
            var start = {
                choose: function(datas){
                    end.min = datas; //开始日选好后，重置结束日的最小日期
                    end.start = datas //将结束日的初始值设定为开始日
                }
            };

            var end = {
                choose: function(datas){
                    start.max = datas; //结束日选好后，重置开始日的最大日期
                }
            };

            $('#start').click(function(){
                start.elem = this;
                laydate({
                    elem: this, //需显示日期的元素选择器
                    event: 'click', //触发事件
                    format: 'YYYY-MM-DD hh:mm:ss' //日期格式
				});
            });


			layer.photos({
			  photos: '#layer-photos-demo'
			  ,closeBtn: 1
			  ,anim: 0 //0-6的选择，指定弹出图片动画类型，默认随机（请注意，3.0之前的版本用shift参数）
			});


            // 购买产品
            $(document).on("click", ".buy", function() {
                var id=this.id;
                layer.open({
                    type:2
                    ,area:['100%', '90%']
                    ,title:"双击选择商品"
                    ,content: '${base}/goods/goodsList'
                });
            });

            //删除
            $(document).on("click", ".del", function() {
                var obj=this.parentNode.parentNode;
                $(obj).empty();
              //  .removeChild( this.parentNode);

            });

		});
	</script>
</body>
</html>